//
//  ExchangeCouponsViewController.h
//  Truffle
//
//  Created by raca on 03/03/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <GameKit/GameKit.h>
#import "Coupon.h"

typedef enum {
	iServer,
	iClient
} exchangeNetwork;


@interface ExchangeCouponsViewController : UIViewController <GKPeerPickerControllerDelegate, GKSessionDelegate, UIAlertViewDelegate> {
	Coupon          *currentCoupon;
	int		         peerStatus;
	// networking
	int				fieldsRecieved;
	GKSession		*exchangeSession;
	int				 exchangeUniqueID;
	NSString		*exchangePeerId;
	// les champs du coupon a recevoir
	NSString		*myIdCoupon;
	NSString		*myName;
	NSString		*myPosition;
	NSString		*myProvider;
	NSString		*myCouponCode;
	NSString		*myDescriptions;
}


@property(nonatomic, retain) Coupon	 *currentCoupon;
@property(nonatomic, retain) GKSession	 *exchangeSession;
@property(nonatomic, copy)	 NSString	 *exchangePeerId;



/*
 * initialize the controller with myCoupon as coupon and aPeerMode as the peer to use. 
 * aPeerMode : 0 if the peer mode to use is server, 1 if client mode.
 */
- (id) initWithMyCoupon:(Coupon*)myCoupon andPeerStatus:(exchangeNetwork) aPeerStatus;


- (void)startPicker;
- (void)invalidateSession:(GKSession *)session;
- (void)sendNetworkPacket:(GKSession *)session withData:(NSData *)data;
- (void) sendCoupon;


@end